/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package jigdo.data.template.section.DESCEntries;

import jigdo.data.template.section.TemplateSection;

/**
 *
 * @author John R Sohn
 */
public class TemplateDESCFileInfoEntry extends TemplateDESCEntry {
    
      public TemplateDESCFileInfoEntry(TemplateSection parent, int ordinalPos, long lastOffset)
    {
        super(parent, ordinalPos,lastOffset);
    }
    
    /**
     * 6      fileLen       "Length in bytes of file contained in image"
     */
    public long FileLength;
    
    /**
     * 8      fileRsync     "RsyncSum64 of first blockLen bytes of the file.
     *                  fileLen < blockLen never happens."
     */
    public long FileSyncSum;
    
    /**
     *16      fileMD5       "MD5 checksum of the file"
    */
    public byte[] FileMD5;
    
    public String FileMD5Base64;
    
    @Override
     public int ReadEntry(byte[] data, int startindex)
    {
        FileLength =  jigdo.utils.ByteUtils.GetIntFromBytes(data, startindex,6);
        startindex+=6;
        
        this.DataSize = FileLength;
        
        FileSyncSum = jigdo.utils.ByteUtils.GetIntFromBytes(data, startindex, 8);
        startindex+=8;
        
        FileMD5 = new byte[16];
        
        System.arraycopy(data, startindex, FileMD5, 0 , 16);
        
        startindex+=16;
        
        FileMD5Base64 = jigdo.utils.ByteUtils.GetJigdo64(FileMD5);
      
        return startindex;
    }
}
